<?php
namespace App\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
class StoreRequest extends FormRequest{



	public function authorize()
    {
        return true;
    }


    //验证规则
    protected $rules = [
        'account' => 'required|between:3,16',
        'password' => 'required',
        'phone'=>'required',
        'contacts_name' => 'required',
        'un_name'=>'required',
        'effective_time'=>'required',
    ];




    public function messages() {
        return  [
            'account.required' => '请输入账号',
            'account.between' => '账号请在3到12位之间',
            'password.min'=> '密码最少长度为:min',
            'password.required' => '密码不能为空',
            'contacts_name.required' => '用户姓名不能为空',
            'phone.required'=>'请输入手机号码',
            'un_name.required'=>'请输入平台名称',
        ];

    }


    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {

        $rules = $this->rules;

        if (Request::getPathInfo() == '/adminapi/store/add')//如果是store添加方法
        {

            $rules['password'] = 'required|min:6';
        }
        return $rules;

    }





}






